home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************/
- /* (C) 1993,1994 R. NADE - M. GRANDCHAMP - All Rights Reserved */
- /*****************************************************************************/
- /* This source-code is NOT public domain nor Freeware, this is part of */
- /* 'The C Programming Package' which is Shareware. */
- /* If you use this code, please register and get a free Full-VGA version */
- /*****************************************************************************/
- /*----------------*
- * CPPLMEN1.C *
- * Menu manager1 *
- * Files *
- *----------------*/
-
- /* Included Files */
- # include <stdio.h>
- # include <io.h>
- # include <dos.h>
- # include <fcntl.h>
- # include <bios.h>
- # include <stdlib.h>
- # include <conio.h>
-
- /* Global Variables */
- extern int bm,i,j,k,l,m,n,t,x,x1,x2,xm,y,y1,y2,ym,z,menu0,menu1,return1;
- extern int colour1,colour2,colour3,colour4,colour5,return2;
- extern unsigned char c0,c1,trashcan[];
-
- /*----------------------*
- * CHOICE DISPLAY HELP1 *
- *----------------------*/
- void choice_display_help1()
- {
- /* We display the help that concerns the line on */
- /* which is the menu cursor (in red). */
- if(menu1==1){
- /* Open a file */
- display_help("FILES ",5,2,1); restore_help_screen();
- }
- if(menu1==2){
- /* Create a new file */
- display_help("FILES ",6,3,1); restore_help_screen();
- }
- if(menu1==3){
- /* Save the info. in the current file */
- display_help("FILES ",7,4,1); restore_help_screen();
- }
- if(menu1==4){
- /* available */
- display_help("FILES ",8,5,1); restore_help_screen();
- }
- if(menu1==5){
- /* Directory manager */
- display_help("FILES ",9,6,1); restore_help_screen();
- }
- if(menu1==6){
- /* Directory change */
- display_help("FILES ",10,7,1); restore_help_screen();
- }
- if(menu1==7){
- /* available */
- display_help("FILES ",11,8,1); restore_help_screen();
- }
- if(menu1==8){
- /* Print */
- display_help("FILES ",12,9,1); restore_help_screen();
- }
- if(menu1==9){
- /* Copy to file */
- display_help("FILES ",13,10,1); restore_help_screen();
- }
- if(menu1==10){
- /* Quit to DOS */
- display_help("FILES ",14,11,1); restore_help_screen();
- }
- }
- /*----------------*
- * GET THE MOUSE1 *
- *----------------*/
- int get_the_mouse1()
- {
- /* If we choose with the mouse */
- /* Only available for menu 1 */
- if(ym==1){
- /* We clicked on the first line, certainly */
- /* To change of menu. */
- x=get_the_mouse0();
- menu0=x; return(-2);
- }
- if((xm>1)&&(xm<19)){
- if(ym==3){
- /* Open a file */
- menu1=1; return(1);
- }
- if(ym==4){
- /* Create a new file */
- menu1=2; return(1);
- }
- if(ym==5){
- /* Save the info. in a file */
- menu1=3; return(1);
- }
- if(ym==6){
- /* Choix (available) */
- menu1=4; return(1);
- }
- if(ym==8){
- /* Directory manager */
- menu1=5; return(1);
- }
- if(ym==9){
- /* Directory change */
- menu1=6; return(1);
- }
- if(ym==10){
- /* (available) */
- menu1=7; return(1);
- }
- if(ym==12){
- /* print */
- menu1=8; return(1);
- }
- if(ym==13){
- /* copy to file */
- menu1=9; return(1);
- }
- if(ym==15){
- /* Quit */
- menu1=10; return(-1);
- }
- }
- /* If we clicked outside the menu zone */
- /* we want to erase the menu and return to menu 0 */
-
- menu0=0; return(-2);
- }
- /*---------------------*
- * GET KEYBOARD INPUT1 *
- *---------------------*/
- int get_keyboard_input1()
- {
- /* Standard keyboard keys */
- if(c1==27){
- /* <Esc> we want to go back to menu0 */
- menu0=0; return(-2);
- }
- if((c1==81)||(c1==113)){
- /* <Q> <q> quit */
- menu1=10; return(-1);
- }
- if(c1==13){
- /* <Enter> execute the command */
- return(1);
- }
- if((c1==79)||(c1==111)){
- /* <O> <o> Open file */
- menu1=1; return(1);
- }
- if((c1==78)||(c1==110)){
- /* <N> <n> Create new file */
- menu1=2; return(1);
- }
- if((c1==83)||(c1==115)){
- /* <S> <s> Save info. in current file */
- menu1=3; return(1);
- }
- if((c1==65)||(c1==97)){
- /* <A> <a> Save as... */
- menu1=4; return(1);
- }
- if((c1==68)||(c1==100)){
- /* <D> <d> Directory manager */
- menu1=5; return(1);
- }
- if((c1==66)||(c1==98)){
- /* <B> <b> Back to the default directory */
- menu1=6; return(1);
- }
- if((c1==82)||(c1==114)){
- /* <R> <r> Recording the file */
- menu1=7; return(1);
- }
- if((c1==80)||(c1==112)){
- /* <P> <p> Print */
- menu1=8; return(1);
- }
- if((c1==84)||(c1==116)){
- /* <T> <t> copy to a file */
- menu1=9; return(1);
- }
- return(0);
- }
- /*-----------------*
- * SPECIAL DECODE1 *
- *-----------------*/
- int special_decode1()
- {
- /* For the 2-bytes coded keys, this is the second byte */
- if(c1==59){
- /* Function key <F1> = help */
- return(22);
- }
- k=get_special_menu00();
- if(k>0) return(-2);
- if(c1==72){
- /* Up arrow */
- if(menu1>1) menu1--;
- else menu1=10;
- return(0);
- }
- if(c1==80){
- /* Down arrow */
- if(menu1<10) menu1++;
- else menu1=1;
- return(0);
- }
- return(0);
- }
- /*--------------*
- * MENU CHOICE1 *
- *--------------*/
- int menu_choice1()
- {
- /* We do nothing until a key is pressed */
- /* or we pressed a mouse button. */
- /* We use the 'l' return to test if the key pressed */
- /* or the mouse choice is one we are waiting for */
- /* else we wait a valid key */
- /* Notice that Up and Down arrows only move the cursor */
- /* and we need to confirm it with <Enter> */
- while(1){
- if(kbhit()){
- /* If we pressed a key */
- c1=getch();
- if(c1>0){
- t=get_keyboard_input1(); break;
- }
- else{
- /* Key coded on 2 bytes */
- c1=getch();
- t=special_decode1(); break;
- }
- }
- /* Else we test the mouse */
- get_mouse_state();
- if(bm==1){
- /* We pressed a mouse button */
- t=get_the_mouse1(); break;
- }
- }
- /* We translate the result and send it back */
- return(t);
- }
- /*--------------------*
- * DISPLAY MENU LINE1 *
- *--------------------*/
- void display_menu_line1()
- {
- /* First we display the chosen menu0 */
- textattr(colour5);
- gotoxy(1,1); cputs(" Files ");
- /* Same thing for the selected line */
- if(menu1==1){
- gotoxy(3,3); cputs(" Open ");
- }
- if(menu1==2){
- gotoxy(3,4); cputs(" New ");
- }
- if(menu1==3){
- gotoxy(3,5); cputs(" Save ");
- }
- if(menu1==4){
- gotoxy(3,6); cputs(" save As... ");
- }
- if(menu1==5){
- gotoxy(3,8); cputs(" Directory mgr ");
- }
- if(menu1==6){
- gotoxy(3,9); cputs(" Back deflt dir ");
- }
- if(menu1==7){
- gotoxy(3,10); cputs(" Record file ");
- }
- if(menu1==8){
- gotoxy(3,12); cputs(" Print ");
- }
- if(menu1==9){
- gotoxy(3,13); cputs(" To a file ");
- }
- if(menu1==10){
- gotoxy(3,15); cputs(" Quit to DOS ");
- }
- }
- /*----------------------*
- * DISPLAY KEY LETTER 1 *
- *----------------------*/
- void display_key_letter1()
- {
- textattr(116);
- gotoxy(4,3); cputs("O");
- gotoxy(4,4); cputs("N");
- gotoxy(4,5); cputs("S");
- gotoxy(9,6); cputs("A");
- gotoxy(4,8); cputs("D");
- gotoxy(4,9); cputs("B");
- gotoxy(4,10); cputs("R");
- gotoxy(4,12); cputs("P");
- gotoxy(4,13); cputs("T");
- gotoxy(4,15); cputs("Q");
- }
- /*---------------*
- * DISPLAY MENU1 *
- *---------------*/
- void display_menu1()
- {
- /* To avoid the trace of the previous mouse position */
- /* we hide it during the display, */
- /* and show it when the line has been displayed. */
- hide_the_mouse(); textattr(colour2);
- gotoxy(1,2); cputs(" ┌────────────────┐ ");
- gotoxy(1,3); cputs(" │ Open │ ");
- gotoxy(1,4); cputs(" │ New │ ");
- gotoxy(1,5); cputs(" │ Save │ ");
- gotoxy(1,6); cputs(" │ save As │ ");
- gotoxy(1,7); cputs(" ├────────────────┤ ");
- gotoxy(1,8); cputs(" │ Directory mgr │ ");
- gotoxy(1,9); cputs(" │ Back Deflt Dir │ ");
- gotoxy(1,10); cputs(" │ Record File │ ");
- gotoxy(1,11); cputs(" ├────────────────┤ ");
- gotoxy(1,12); cputs(" │ Print │ ");
- gotoxy(1,13); cputs(" │ To a file │ ");
- gotoxy(1,14); cputs(" ├────────────────┤ ");
- gotoxy(1,15); cputs(" │ Quit to DOS │ ");
- gotoxy(1,16); cputs(" └────────────────┘ ");
- display_key_letter1(); display_menu_line1();
- show_the_mouse();
- }
- /*----------------*
- * MENU MANAGER 1 *
- *----------------*/
- int menu_manager1()
- {
- restore_screen(); return1=0;
- while(1){
- display_menu1(); return1=menu_choice1();
- if(return1==-2) return(-2);
- if(return1==-1) return(-1);
- if(return1==22) choice_display_help1();
- display_menu1();
- if(return1==1){
- /* We execute the selected function */
- if(menu1==10){
- /* we want to quit to DOS */
- return(-1);
- }
- if(menu1==1){
- /* Open a file */
- gotoxy(1,25); printf(" Open a file. Press <SPACE> please.");
- getch(); /* We erase the line */
- gotoxy(1,25); printf(" ");
- }
- if(menu1==2){
- /* create a new file */
-
- }
- if(menu1==3){
- /* Save info. in the current file */
-
- }
- if(menu1==4){
- /* Save as */
-
- }
- if(menu1==5){
- /* Directory/drives manager */
- directory_change();
- }
- if(menu1==6){
- /* Back to the default directory stored in the */
- /* service file in "path" */
- back_to_default_directory();
- }
- if(menu1==7){
- /* Recording of the files Cf MODFIC3.C */
- file_recording();
- }
- if(menu1==8){
- /* Print */
-
- }
- if(menu1==9){
- /* Copy to a file */
-
- }
- }
- }
- }
- /* End of the Module *//*----------------*/
-